package com.example.androidapp2.DbClasses;

import java.util.Calendar;
import com.xyzdesa.droidnomy.R;
import android.content.Context;
import android.graphics.Color;
import android.widget.TextView;

public class Utils {
	public static Context Ctx;
	static final String colorPositivo = "#9DCD39";
	static final String colorNegativo = "#E73F2F";
	public static final String medioEft = "EFT";
	public static final String medioCred = "TRJ";
	public static final String codIngreso = "In";
	public static final String codEgreso = "Eg";
	public static final String codEspanol = "es";
	public static final String codIngles = "en";
	
	//Preferences Consts
	public static final String Prfs = "preferences";
	public static final String Prf_LauncCounter = "lnchCounter"; 
	public static final String Prf_NotShowRate = "Rate_NotShow";
	public static final String Prf_Rated = "Rate_Rated";
	
	public static final String UrlFacebook = "http://www.facebook.com/DroidNomy";
	public static final String UrlAyuda = "http://www.youtube.com/user/AyudaDroidNomy";

	public static String GetFecha()
	{
		Calendar c = Calendar.getInstance(); 

		String fecha = (
				((c.get(Calendar.DATE)<10)?"0"+String.valueOf( c.get(Calendar.DATE)):String.valueOf( c.get(Calendar.DATE)))+
				((c.get(Calendar.MONTH)+1<10)?"0"+String.valueOf( c.get(Calendar.MONTH)+1):String.valueOf( c.get(Calendar.MONTH)+1))+
				((c.get(Calendar.YEAR)<10)?"0"+String.valueOf( c.get(Calendar.YEAR)):String.valueOf( c.get(Calendar.YEAR)))+
				((c.get(Calendar.HOUR_OF_DAY)<10)?"0"+String.valueOf( c.get(Calendar.HOUR_OF_DAY)):String.valueOf( c.get(Calendar.HOUR_OF_DAY)))+
				((c.get(Calendar.MINUTE)<10)?"0"+String.valueOf( c.get(Calendar.MINUTE)):String.valueOf( c.get(Calendar.MINUTE)))
				);

		return fecha;
	}

	public static String GetMesAnio()
	{
		Calendar c = Calendar.getInstance();
		return ((c.get(Calendar.MONTH)+1<10)?"0"+String.valueOf( c.get(Calendar.MONTH)+1):String.valueOf( c.get(Calendar.MONTH)+1))+
				((c.get(Calendar.YEAR)<10)?"0"+String.valueOf( c.get(Calendar.YEAR)):String.valueOf( c.get(Calendar.YEAR)));		
	}
	
	public static int GetDia()
	{
		Calendar c = Calendar.getInstance();
		return c.get(Calendar.DAY_OF_MONTH);
	}
	
	public static String ChangeDateToEn(String fecha)
	{
		String[] ls = fecha.split("/");
		return ls[1]+"/"+ls[0]+"/"+ls[2];
	}
	
	public static String GetFecha(int dia, int mes, int anio)
	{
		
		return ((dia<10)?"0"+String.valueOf(dia):String.valueOf(dia)) +
			   ((mes<10)?"0"+String.valueOf(mes):String.valueOf(mes)) +
		       anio+"0000";					   
	}

	public static String GetDefaultIngreso()
	{
		return Ctx.getResources().getString(R.string.pupIngresos);	
	}

	public static void SetControlColor(TextView ctrl, boolean positivo)
	{
		if(positivo)
			ctrl.setTextColor(Color.parseColor(colorPositivo));
		else
			ctrl.setTextColor(Color.parseColor(colorNegativo));
	}
	
	public static int GetColor(boolean positivo)
	{
		if(positivo)
			return Color.parseColor(colorPositivo);
		else
			return Color.parseColor(colorNegativo);
	}
	
	public static int ConvertDpToPx(Double dp)
	{
		final float scale = Ctx.getResources().getDisplayMetrics().density;
		return (int) (dp * scale + 0.5f);		
	}
	public static int ConvertDpToPx(int dp)
	{
		final float scale = Ctx.getResources().getDisplayMetrics().density;
		return (int) (dp * scale + 0.5f);		
	}
}


